import React from 'react';
import style from '../../DataBoard.css';
import EleEnergyTrend from './EleEnergyTrend';
import MonthSaveTarget from './MonthSaveTarget';
import EnergyCalender from './EnergyCalender';
import WaterCostTrend from './WaterCostTrend';
import COPTrend from './COPTrend';
import EERTrend from './EERTrend';
import ColdTrend from './ColdTrend';
import CarbonTrend from './CarbonTrend';
import CoalTrend from './CoalTrend';
import ColdPrice from './ColdPrice';
import CostPercent from './CostPercent';
// import MultiEnergyCost from './MultiEnergyCost';
// import EleTimeCost from './EleTimeCost';
// import FieldEnergyCost from './FieldEnergyCost';
// import CarbonTrend from './CarbonTrend';
// import CoalTrend from './CoalTrend';
import ScrollTable from './ScrollTable';
// import CostCalender from './CostCalender';

const componentMaps = {
    A:EleEnergyTrend,
    B:MonthSaveTarget,
    C:EnergyCalender,
    D:WaterCostTrend,
    E:CarbonTrend,
    F:CoalTrend,
    G:ColdPrice,
    H:CostPercent,
    I:COPTrend,
    J:ScrollTable,
    K:EERTrend,
    L:ColdTrend
};

function ChartCardList({ list, theme, chartMaps, onDispatch }){
    return (
        <div style={{ height:'100%', overflow:'hidden auto' }}>
            {
                list.map((item, index)=>{
                    let Com = componentMaps[item.key] ? componentMaps[item.key] : ()=>null ;
                    return (
                        <div
                            key={item.key}
                            className={style['card-container-wrapper']}
                            style={{ width: '50%', height: '50%' }}
                        >
                            <Com
                                item={item}
                                theme={theme}
                                chartMaps={chartMaps}
                                onDispatch={onDispatch}
                            />
                        </div>
                    )
                })
            }
        </div>
    )
}

export default React.memo(ChartCardList);